package view;
import java.awt.Toolkit;
import java.util.ArrayList;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Tray;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

import controller.roomManagement.Interface.IRoomManageController;
import controller.roomManagement.Implementation.RoomManageController;



public class Detail {
	protected Shell shell;
	IRoomManageController RMC;
	int roomID;
	public Detail(IRoomManageController roomManageController,int roomID){
	    this.RMC = (RoomManageController)roomManageController;
	    this.roomID = roomID;
	}

	/**
	 * Open the window.
	 * @wbp.parser.entryPoint
	 */
	public void open() {
		Display display = Display.getDefault();
		
		
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		//获取屏幕高度和宽度
        int screenH = Toolkit.getDefaultToolkit().getScreenSize().height;
        int screenW = Toolkit.getDefaultToolkit().getScreenSize().width;
		
		shell = new Shell(SWT.CLOSE | SWT.MIN);
		shell.setImage(SWTResourceManager.getImage(Detail.class, "/img/GMS.png"));
		shell.setSize(270, 220);
		shell.setLocation((screenW - 270)/2,(screenH - 220)/2);
		shell.setText("\u623F\u95F4\u8BE6\u7EC6\u4FE1\u606F");
		
		String[] roomInfo = RMC.getRoomInfoByRId(roomID).split("/");
		
		/*String[] roomUser = roomInfo[3].split(",");
		for(int i=0;i<roomUser.length;i++){
			System.out.println(roomUser[i]);
		}*/
		Label lbl_0 = new Label(shell, SWT.NONE);
		lbl_0.setBounds(25, 10, 61, 17);
		lbl_0.setText("\u623F\u95F4ID\uFF1A");
		
		Label lbl_roomID = new Label(shell, SWT.NONE);
		lbl_roomID.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lbl_roomID.setBounds(92, 10, 145, 18);
		lbl_roomID.setText(roomInfo[0]);//房间ID
		
		Label lbl_1 = new Label(shell, SWT.NONE);
		lbl_1.setBounds(25, 35, 61, 17);
		lbl_1.setText("\u623F\u95F4\u4E3B\u9898\uFF1A");
		
		Label lbl_roomName = new Label(shell, SWT.NONE);
		lbl_roomName.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lbl_roomName.setBounds(92, 35, 145, 18);
		lbl_roomName.setText(roomInfo[2]);//房间主题
		
		Label lbl_2 = new Label(shell, SWT.NONE);
		lbl_2.setBounds(25, 60, 61, 17);
		lbl_2.setText("\u521B\u5EFA\u8005ID\uFF1A");
		
		Label lbl_createrID = new Label(shell, SWT.NONE);
		lbl_createrID.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lbl_createrID.setBounds(92, 60, 145, 18);
		lbl_createrID.setText(roomInfo[1]);//创建者ID
		
		Label lbl_userID = new Label(shell, SWT.NONE);
		lbl_userID.setBounds(25, 90, 192, 17);
		lbl_userID.setText("已加入房间用户ID：");
		
		Label lbl_IDList = new Label(shell, SWT.WRAP);
		lbl_IDList.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lbl_IDList.setBounds(25, 115, 212, 67);
		lbl_IDList.setText(roomInfo[3]);//已加入用户ID
		
	}
}
